from commonDaoApi.CommonUserDao import BaseUserDao
from pojo.BaseLogin import BLogin
import traceback


class TTZUserDao(BaseUserDao):
    def updateUserInfo(self, BLogin):
        sql = "update user set user_token = %s,USER_COBIN = %s where user_phone = %s and APP_ID = %s"
        values = (BLogin.userToken, BLogin.coinBean, BLogin.userPhone,BLogin.appId)
        self.cursor.execute(sql, values)
        self.db.commit()

    def updateTodayWinAmount(self, BLogin):
        sql = "update user set TODAY_WIN_AMOUNT = %s where USER_PHONE = %s and APP_ID = %s"
        values = (BLogin.todayWinAmount, BLogin.userPhone,BLogin.appId)
        self.cursor.execute(sql, values)
        self.db.commit()

    def queryAllUser(self,BLogin):
        all_phone_numbers = []
        try:
            sql = "select * from user where APP_ID = %s"
            # sql = "select * from user"
            values = (BLogin.appId,)
            self.cursor.execute(sql,values)
            result = self.cursor.fetchall()
            for row in result:
                all_phone_numbers.append(row[6])
            return all_phone_numbers
        except:
            print( traceback.format_exc())
            return all_phone_numbers


if __name__ == '__main__':
    user = TTZUserDao()
    a = BLogin()
    a.appId = 1
    print("all_phone_numbers",user.queryAllUser(a))